﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
    [TestClass]
    public class UserData_11_Error_Test
    {
        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test01_Equals()
        {
            UserData_11_Error userData = new UserData_11_Error(eErrorCode.DataOutOfRange, 0x99);

            {
                // completely different type - NOT equal
                object dummyObject = new object();
                Assert.IsFalse(userData.Equals(dummyObject));
            }

            {
                // different derived type 
                ReportType_Device reportType = new ReportType_Device(false, eReportSubType_Device.General);
                UserData userData2Compare = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType);
                Assert.IsFalse(userData.Equals(userData2Compare));
            }

            {
                // same object - equal
                UserData_11_Error userData2Compare = new UserData_11_Error(userData.ErrorCode, userData.Device);
                Assert.IsTrue(userData.Equals(userData2Compare));
            }

            {
                // different property values - NOT equal
                eErrorCode errorCode = eErrorCode.WrongSecurityCode;
                if (userData.ErrorCode == eErrorCode.WrongSecurityCode)
                {
                    errorCode = eErrorCode.FunctionNotSupportedByAddress;
                }
                UserData_11_Error userData2Compare = new UserData_11_Error(errorCode, userData.Device);
                Assert.IsFalse(userData.Equals(userData2Compare));
            }

            {
                // different property values - NOT equal
                UserData_11_Error userData2Compare = new UserData_11_Error(userData.ErrorCode, (byte) (userData.Device + 1));
                Assert.IsFalse(userData.Equals(userData2Compare));
            }
        }

        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test02_GetHashCode()
        {
            UserData_11_Error userData = new UserData_11_Error(eErrorCode.ChecksumError, 0x33);
            int hashCode01 = userData.GetHashCode();
        }

        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test03_ToString()
        {
            UserData_11_Error userData = new UserData_11_Error(eErrorCode.ChecksumError, 0x03);
            string string01 = userData.ToString();
            Assert.IsNotNull(string01);
        }
    }
}
